////package com.sport.controller;
////
////
////import com.sport.service.SysUserService;
////import com.sport.utils.MD5Utils;
////import com.sport.utils.MailUtils;
////import com.sport.utils.QiniuUtils;
////import com.sport.utils.Result;
////import com.sport.vo.MailVo;
////import io.swagger.annotations.Api;
////import io.swagger.annotations.ApiOperation;
////import org.springframework.beans.factory.annotation.Autowired;
////import org.springframework.security.crypto.password.PasswordEncoder;
////import org.springframework.web.bind.annotation.*;
////import org.springframework.web.multipart.MultipartFile;
////
////import java.util.Random;
////import java.util.UUID;
//
//import com.sport.service.SysUserService;
//import com.sport.utils.MailUtils;
//import com.sport.utils.QiniuUtils;
//import com.sport.utils.Result;
//import com.sport.vo.MailVo;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.web.bind.annotation.*;
//import org.springframework.web.multipart.MultipartFile;
//
//import java.util.Random;
//import java.util.UUID;
//
///**
// * 文件上传、短信发送、邮件发送请求
// */
//@RestController
//@RequestMapping("/tool")
//@Api(tags="图片上传")
//public class ToolController {
//    @Autowired
//    MailUtils mailUtils;
//
//    @Autowired
//    PasswordEncoder passwordEncoder;
//
//    @Autowired
//    SysUserService sysUserService;
//
//QiniuUtils qiniuUtils;
//    @PostMapping("/upload")
//    public Result webUpload(@RequestParam("file") MultipartFile file) {
//        if (file.isEmpty()) {
//            return new Result(false, "上传图片失败");
//        }
//        //获取文件名
//        String originalFilename = file.getOriginalFilename();
//        //获取文件后缀
//        int index = originalFilename.lastIndexOf(".");
//        String suffix = originalFilename.substring(index);
//        String fileName = UUID.randomUUID().toString().replace("-", "") + suffix;
//        System.out.println("suffix是====》{},fileName是===={}"+suffix+fileName);
//        //开始上传
//        try {
//            System.out.println("进入try方法");
//            qiniuUtils.upload(file.getInputStream(), fileName);
//            return new Result(true, "上传成功", fileName);
//        } catch (Exception e) {
//            return new Result(false, "上传文件失败");
//        }
//    }
//
////    @PostMapping("/upload")
////    public Result webUpload(@RequestBody MultipartFile file) throws IOException {
////        System.out.println("webUpload开始");
////        String url=qiniuUtils.upload(file.getInputStream(),file.getOriginalFilename());
////        return Result.success("文件上传成功",url);
////
////    }
////
////    @Autowired
////    aliyunUtils aliyunUtils;
////    @PostMapping("/upload")
////    public Result upload(@RequestBody MultipartFile file) throws IOException {
////        PutObjectResult client = aliyunUtils.client(file.getName(), file.getOriginalFilename());
////        System.out.println(client);
////        return Result.success("文件上传成功",client);
////    }
//
//
//
//    @ApiOperation(value = "忘记密码，如何找回")
//    @PostMapping("/forget/password")
//    public Result forget(@RequestBody MailVo mail){
//        mail.setSubject("个人运动管理平台");
//        Random random=new Random();
//        int password=1000000+random.nextInt(1000000);
//        sysUserService.updatePwdByMail(mail.getReceivers()[0],passwordEncoder.encode(MD5Utils.md5(String.valueOf(password))));
//        mail.setContent("您的新密码"+password+",请妥善保管");
//        System.out.println(mailUtils.sendMail(mail));
//        return Result.success(mailUtils.sendMail(mail));
//    }
//}
